package cn.hgpu.servlet;

import cn.hgpu.mapper.RoleMapper;
import cn.hgpu.pojo.Role;
import cn.hgpu.utils.MybatisUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/admin/addPage")
public class AdminAddPageServlet extends HttpServlet {
    //1.获取mapper
    private RoleMapper roleMapper = MybatisUtils.getMapper(RoleMapper.class);


    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //2.调用方法
        List<Role> list = roleMapper.selectAll();

        req.setAttribute("list1", list);

        //3.跳转界面
        req.getRequestDispatcher("/admin/add.jsp").forward(req,resp);
    }


}
